/**
 * This class is a structure to map an dot element with its type.
 * @author Lucas Venezian Povoa <lucasvenez@gmail.com>
 */
function QuadCollection() {
	
	var elements = new Array();
	var types    = new Array();
	var lines    = new Array();
	var columns  = new Array();
	
	/**
	 * @param element (String) is the element 
	 * @param type (Integer)
	 * @param line (Integer)
	 * @param column (Integer)
	 */
	this.add = function(element, type, line, column) {
		elements.push(element);
		types.push(type);
		lines.push(line);
		columns.push(column);
	};
	
	/**
	 * @returns the element with index value index, null when index is invalid.
	 * @param index (Integer) is the index of the element to be returned.
	 */
	this.get = function(index) {
		if (elements.length > index && index > -1) {
			return [elements[index], types[index], lines[index], columns[index]];
		};
		
		return null;
	};
	
	/**
	 * This method removes the elements with index passed as arguments.
	 * @returns true when removed or false otherwise.
	 */
	this.remove = function() {
		
		if (arguments.length > 0) {
			for(var i = 0; i < arguments.length; i++) {
				
			    var index = arguments[i];
			    
			    for (var j = i + 1; j < arguments.length; j++)
			    	if (arguments[j] > index)
			    		arguments[j] -= 1;
			    
			    if (elements.length > index && index > -1) {
					
					elements.splice(index, 1);
					types.splice(index, 1);
					lines.splice(index, 1);
					columns.splice(index, 1);
			    
			    } else
			    	return false;
			}
			
			return true;
		}

		return false;
	};
	
	/**
	 * @return the size of the structure.
	 */
	this.getSize = function() {
		return elements.length;
	};
	
	this.clone = function() {
		
		var result = new QuadCollection();
		
		var e = elements.slice(0);
		var t = types.slice(0);
		var l = lines.slice(0);
		var c = columns.slice(0);
		
		for (var i = 0; i < e.length; i++)
			result.add(e[i], t[i], l[i], c[i]);
		
		return result;
	};
};